/*
    Dijjer - A Peer to Peer HTTP Cache
    Copyright (C) 2008 Change.Tv, Inc, Mathias De Maré

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package dijjer.io.comm;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.InputStream;
import java.io.IOException;

import dijjer.io.WritableToDataOutputStream;
import dijjer.util.VeryLongInteger;

public abstract class AbstractPeer implements WritableToDataOutputStream {
	protected VeryLongInteger hash;
	
	public AbstractPeer() throws Exception { }
	public AbstractPeer(DataInputStream dis) throws IOException { }
	
	public abstract boolean isNull();
	
	public boolean equals(Object o) {
		if (this == o)
			return true;
		if (!(o instanceof AbstractPeer))
			return false;
		
		final AbstractPeer peer = (AbstractPeer) o;
		
		if (!(peer.hash.equals(hash)))
			return false;
		
		return true;
	}
	
	public VeryLongInteger getHash() {
		return hash;
	}
	
	public abstract int hashCode();
	
	public abstract String toString();
	
	public abstract void writeToDataOutputStream(DataOutputStream dos) throws IOException;
	
}
